
function login() {
    const username = $('.input_txt').val();
    const password = $('.input_pass').val();
    if (username && password) {
        console.log(username, password);
        // $.ajax({
        //     type: "post",
        //     url: "http://localhost:8080/api/v1/admin/user/login",
        //     data: { username, password },
        //     success: function (response) {
        //         // console.log(response);
        //         if (response.code === 200) {
        //             window.localStorage.setItem('token', response.token)
        //             window.location.href = './index.html'
        //         } else {
        //             // alert('帐号或密码错误')
        //             $('.modal-body').html(response.msg)
        //             $('#loginModal').modal('show')
        //         }
        //     }
        // });
        http.ajax({
            type: 'post',
            url: '/admin/user/login',
            data: { username, password },
            success: function (response) {
                console.log(response);
                console.log(username, password);
                if (response.code === 200) {
                    window.localStorage.setItem('token', response.token)
                    window.location.href = './index.html'
                } else {
                    // alert('帐号或密码错误')
                    $('.modal-body').html(response.msg)
                    $('#loginModal').modal('show')
                }
            },
        });
    } else {
        // alert('帐号和密码不能为空')
        $('.modal-body').html('帐号和密码不能为空')
        $('#loginModal').modal('show')
    }
}